<?php

namespace catchAdmin\phone\controller;

use catchAdmin\lm\model\Goods as G;

use catchAdmin\phone\common\Jwt;
use catchAdmin\phone\model\Wxuser;
use catcher\CatchResponse;
use think\facade\Request;
use catchAdmin\permissions\model\Users as U;

use think\Response;

class Goods extends Jwt
{

    public function tjgoodsinfo()
    {
        $data = Request::param();



        $info = (new \catchAdmin\phone\model\Wxuser)->where('openid',$this->openid)->find();
        $i = $data['info'];
        $i['projectid'] = $data['id'];
        $i['openid'] = $this->openid;
        $i['zwphone']  = $info['phone'];
        $i['zwname'] = $info['nickname'];
        $i['status'] = 1;
        $i['cunid'] = Wxuser::where('openid',$this->openid)->find()['cunid'];
        $i['creator_id'] =  U::where('username',Wxuser::where('openid',$this->openid)->find()['qu'])->find()['id'] ;


        if (G::where(['openid'=>$this->openid,'projectid'=>$i['projectid']])->find()){
            return CatchResponse::fail('检测到重复申报,请核实后提交!');
        }
        $db = new G;
        $db->save($i);
        return  CatchResponse::success('ok',200,200);

    }




}